package objectCase;

import java.util.Scanner;

public class GoodsTest {
    public static void main(String[] args) {
        Goods[] arr = new Goods[4];
        Goods g1 = new Goods("1","联想", 5000,23);
        Goods g2 = new Goods("2","戴尔", 6000,10);
        Goods g3 = new Goods("3","华硕", 7000,15);
        Goods g4 = new Goods("4","惠普", 8000,20);
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;
        arr[3] = g4;
        for (Goods goods : arr) {
            System.out.println(goods.getId() + "\t" + goods.getName() + "\t" + goods.getPrice() + "\t" + goods.getCount());
        }
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要购买的商品id");
        //sc.next() 只能输入字符串，不能输入数字
        String id = sc.next();
        System.out.println("请输入要购买的商品数量");
        //sc.nextInt() 只能输入数字，不能输入字符串
        int count = sc.nextInt();
        System.out.println("请输入要支付的金额");
        //sc.nextDouble() 只能输入数字，不能输入字符串
        double money = sc.nextDouble();
        //sc.nextLine() 可以输入字符串，也可以输入数字,可以接收制表符碰到回车才会结束
        //String line = sc.nextLine();

    }
}
